package org.studio.oa.duty;

import java.time.LocalDate;
import java.time.LocalTime;

import org.ctstudio.common.datatype.TimeFragment;
import org.junit.Assert;
import org.junit.Test;

public class TimeFragmentTester {
  @Test
  public void testGetPeriod() {
    Assert.assertEquals(LocalTime.of(6, 51), new TimeFragment(LocalTime.of(10, 44), LocalTime.of(17, 35)).getPeriod());
    Assert.assertEquals(LocalTime.MAX, new TimeFragment(null, null).getPeriod());
  }

  @Test
  public void testLocalDate() {
    Assert.assertEquals(0, LocalDate.of(2016, 3, 15).toEpochDay() - LocalDate.of(2016, 3, 15).toEpochDay());
    Assert.assertEquals(31 + 29 + 14, LocalDate.of(2016, 3, 15).toEpochDay() - LocalDate.of(2016, 1, 1).toEpochDay());
    Assert.assertEquals(-1, LocalDate.of(2016, 3, 15).toEpochDay() - LocalDate.of(2016, 3, 16).toEpochDay());
  }
}
